<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<% String path = request.getContextPath();%>
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>H+ 后台主题UI框架 - 数据表格</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico"> <link href="<%=path%>/admin/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="<%=path%>/admin/css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <!-- Data Tables -->
    <link href="<%=path%>/admin/css/plugins/dataTables/dataTables.bootstrap.css" rel="stylesheet">

    <link href="<%=path%>/admin/css/animate.css" rel="stylesheet">
    <link href="<%=path%>/admin/css/style.css?v=4.1.0" rel="stylesheet">

</head>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>基本 <small>分类，查找</small></h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="dropdown-toggle" data-toggle="dropdown" href="table_data_tables.html#">
                                <i class="fa fa-wrench"></i>
                            </a>
                            <ul class="dropdown-menu dropdown-user">
                                <li><a href="table_data_tables.html#">选项1</a>
                                </li>
                                <li><a href="table_data_tables.html#">选项2</a>
                                </li>
                            </ul>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">

                        <table class="table table-striped table-bordered table-hover dataTables-example">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>用户id</th>
                                <th>收货人名称</th>
                                <th>收货人手机号码</th>
                                <th>详细地址</th>
                                <th>创建时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                                <c:forEach items="${UserAddress}" var="UserAddresss">
                                    <tr class="gradeX">
                                        <td>${UserAddresss.addressId}</td>
                                        <td>${UserAddresss.userId}</td>
                                        <td>${UserAddresss.userName} </td>
                                        <td class="center">${UserAddresss.userPhone}</td>
                                        <td>${UserAddresss.address} </td>
                                        <td class="center">${UserAddresss.createTime}</td>
                                        <td class="center">
                                            <a class="btn btn-sm btn-primary"
                                               href="user?type=userAddressDelete&addressId=${UserAddresss.addressId}" name="delete">删除</a>

                                            <a class="btn btn-sm btn-primary" data-toggle="modal" data-target="#updateModel"  onclick="return  edit(${UserAddresss.addressId})">修改</a>
<%--                                            <a class="btn btn-sm btn-primary" data-toggle="modal" data-target="#updateModel" href="/orange/admin?type=queryOne&id=${admin.id}" >修改</a>--%>
                                            <a class="btn btn-sm btn-primary "  data-toggle="modal" data-target="#myModal">新增</a>
                                        </td>
                                    </tr>
                                </c:forEach>
                            </tbody>
                        </table>

                    </div>
                </div>
            </div>
        </div>

                </div>
            </div>
        </div>
    </div>
    <!-- 弹框代码新增-->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabels">颜色选择</h4>
                </div>
                <div class="modal-body">
                    <div class="input-group colorpicker-component demo demo-auto colorpicker-element">
                        <div >
                            <form action="useraddress?type=userAddressAdd" method="post" role="form" class="form-horizontal m-t" id="commentForms" novalidate="novalidate">
                                <div class="form-group">

                                    <label class="col-sm-4 control-label">用户id：</label>
                                    <div class="col-sm-8">
                                        <input id="userIds" name="userId" minlength="2" type="text" class="form-control" required="" aria-required="true">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">收货人名称：</label>
                                    <div class="col-sm-8">
                                        <input id="userNames" type="text" class="form-control" name="userName" required="" aria-required="true">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">收货人手机号码：</label>
                                    <div class="col-sm-8">
                                        <input id="userPhones" type="text" class="form-control" name="userPhone" required="" aria-required="true">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">详细地址：</label>
                                    <div class="col-sm-8">
                                        <input id="addresss" type="text" class="form-control" name="address" required="" aria-required="true">
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-4 control-label">创建时间：</label>
                                    <div class="col-sm-8">
                                        <input id="createTimes" type="text" class="form-control" name="createTime" required="" aria-required="true">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-3">
                                        <button  class="btn btn-primary" type="submit">提交</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>
    <!-- 弹框代码 修改-->
    <div class="modal fade" id="updateModel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
                    <h4 class="modal-title" id="myModalLabel">颜色选择</h4>
                </div>
                <div class="modal-body">
                    <div class="input-group colorpicker-component demo demo-auto colorpicker-element">
                        <div >


                            <form action="useraddress?type=userAddressUpdate" method="post" role="form" class="form-horizontal m-t" id="commentForm" novalidate="novalidate">
                                <input  hidden="hidden" id="addressId" name="addressId"  type="text" >

                                <div class="form-group">

                                    <label class="col-sm-4 control-label">用户id：</label>
                                    <div class="col-sm-8">
                                        <input id="userId" name="userId" minlength="2" type="text" class="form-control" required="" aria-required="true">
                                        <span style="color: red;display: none" id="updateUserId">该区域不能为空</span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">收货人名称：</label>
                                    <div class="col-sm-8">
                                        <input id="userName" type="text" class="form-control" name="userName" required="" aria-required="true">
                                        <span style="color: red;display: none" id="updateUserName">该区域不能为空</span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">收货人手机号码：</label>
                                    <div class="col-sm-8">
                                        <input id="userPhone" type="text" class="form-control" name="userPhone" required="" aria-required="true">
                                        <span style="color: red;display: none" id="updateUserPhone">该区域不能为空</span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-4 control-label">详细地址：</label>
                                    <div class="col-sm-8">
                                        <input id="address" type="text" class="form-control" name="address" required="" aria-required="true">
                                        <span style="color: red;display: none" id="updateAddress">该区域不能为空</span>
                                    </div>
                                </div>
                                <%--<div class="form-group">
                                    <label class="col-sm-4 control-label">创建时间：</label>
                                    <div class="col-sm-8">
                                        <input id="createTime" type="text" class="form-control" name="createTime" required="" aria-required="true">
                                    </div>
                                </div>--%>
                                <div class="form-group">
                                    <div class="col-sm-4 col-sm-offset-3">
                                        <button  class="btn btn-primary" type="submit" id="submit">提交</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>
        </div>
    </div>

    <!-- 全局js -->
    <script src="<%=path%>/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="<%=path%>/admin/js/bootstrap.min.js?v=3.3.6"></script>
    <script>
        $("#commentForm").submit(
            function () {
                //用户id为空提示setTimeout()
                if ($("#userId").val()==""){
                    $("#updateUserId").show();
                    $("#userId").focus();
                    setTimeout(function(){
                        $("#updateUserId").hide()
                    },3000);
                    return false;
                }
                //收货人名称为空提示
                if ($("#userName").val()==""){
                    $("#updateUserName").show();
                    $("#userName").focus();
                    setTimeout(function(){
                        $("#updateUserName").hide()
                    },3000);
                    return false;
                }
                //收货人手机号码为空提示
                if ($("#userPhone").val()==""){
                    $("#updateUserPhone").show();
                    $("#userPhone").focus();
                    setTimeout(function(){
                        $("#updateUserPhone").hide()
                    },3000);
                    return false;
                }
                //详细地址为空提示
                if ($("#address").val()==""){
                    $("#updateAddress").show();
                    $("#address").focus();
                    setTimeout(function(){
                        $("#updateAddress").hide()
                    },3000);
                    return false;
                }
                return true;
            }
        );
        //删除按钮提示
        $("[name='delete']").click(function () {

        });
    </script>


    <script src="<%=path%>/admin/js/plugins/jeditable/jquery.jeditable.js"></script>

    <!-- Data Tables -->
    <script src="<%=path%>/admin/js/plugins/dataTables/jquery.dataTables.js"></script>
    <script src="<%=path%>/admin/js/plugins/dataTables/dataTables.bootstrap.js"></script>

    <!-- 自定义js -->
    <script src="<%=path%>/admin/js/content.js?v=1.0.0"></script>
   <script type="text/javascript">
            //修改用户地址信息
           function  edit(id) {
                   $.ajax({
                       url:"useraddress?type=userAddressByIdSelect&addressId="+id,
                       type:"post",
                       dataType:"json",
                       success:function (data) {
                           $("#addressId").val(id);
                           $("#userId").val(data.userId);
                           $("#userName").val(data.userName);
                           $("#userPhone").val(data.userPhone);
                           $("#createTime").val(data.createTime);
                           $("#address").val(data.address);
                       }
                   })
           }

   </script>

    <!-- Page-Level Scripts -->
    <script>
        $(document).ready(function () {
            $('.dataTables-example').dataTable();

            /* Init DataTables */
            var oTable = $('#editable').dataTable();

            /* Apply the jEditable handlers to the table */
            oTable.$('td').editable('../example_ajax.php', {
                "callback": function (sValue, y) {
                    var aPos = oTable.fnGetPosition(this);
                    oTable.fnUpdate(sValue, aPos[0], aPos[1]);
                },
                "submitdata": function (value, settings) {
                    return {
                        "row_id": this.parentNode.getAttribute('id'),
                        "column": oTable.fnGetPosition(this)[2]
                    };
                },

                "width": "90%",
                "height": "100%"
            });


        });

        function fnClickAddRow() {
            $('#editable').dataTable().fnAddData([
                "Custom row",
                "New row",
                "New row",
                "New row",
                "New row"]);

        }
    </script>

    <script type="text/javascript" src="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
    <!--统计代码，可删除-->
</body>

</html>
